package com.tekj.cxqcb.view.Module.adapter;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;
import com.tekj.cxqcb.R;
import com.tekj.cxqcb.operation.resultBean.ShopGoodsListBean;
import com.tekj.cxqcb.view.Module.activity.NotShelfGoodsActivity;
import com.tekj.cxqcb.view.Module.activity.StoreModule.AddStoreActivity;

import java.util.List;

/**
 * 服务选择的商品列表
 */
public class NewStoreDetailsAdapter extends BaseQuickAdapter<ShopGoodsListBean.DataBean.TypeLevelList, BaseViewHolder> {

    public NewStoreDetailsAdapter(@Nullable List<ShopGoodsListBean.DataBean.TypeLevelList> data) {
        super(R.layout.item_new_store, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final ShopGoodsListBean.DataBean.TypeLevelList item) {

        helper.setText(R.id.tv_goods_name, item.getLevelTwoName());
        if (item.getTypeImg() != null && !item.getTypeImg().equals(""))
            Picasso.get().load(item.getTypeImg()).into((ImageView) helper.getView(R.id.img_photo));

        RecyclerView rvGoods = helper.getView(R.id.rv_goods);
        rvGoods.setLayoutManager(new LinearLayoutManager(mContext));
        final NewStoreDetails2Adapter adapter = new NewStoreDetails2Adapter(item.getList());
        rvGoods.setAdapter(adapter);

//        helper.setGone(R.id.rv_goods, item.isSelect2());
//        helper.setImageResource(R.id.img_isgoods, item.isSelect() ? R.mipmap.img_gx : R.mipmap.img_wgx2);

        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = new Intent(mContext, AddStoreActivity.class);
                intent.putExtra("data", item.getList().get(position));
                mContext.startActivity(intent);
            }
        });



    }

}
